class placeIntro {
    constructor(mongoose) {
        this.mongoose = mongoose
        this.Schema = mongoose.Schema
        // AnimeIntro模板
        this.placeIntro = new this.Schema({

            id: Number,
            name: String,
            place: String,
            time: Date,
            imgUrl: String,

        })
        this.modal = this.mongoose.model('Place', this.placeIntro)
    }

    // @paras1 查询条件 动漫名字数组
    // @paras2 查询结果过滤器
    // 返回查询结果
    placesFind(body) {
        return this.modal.find().sort({ id: 1 }).skip(10 * body.page).limit(10)

    }
    placeFind(body) {
        return this.modal.find({ id: body.id })

    }
    placeAdd(body) {
        console.log(body)
        if (body.imgUrl === '') {
            var Place = new this.modal({
                id: body.id,
                name: body.name,
                time: new Date(),
                place: body.place,
                imgUrl: '',
            })
            return Place.save()
        } else {
            return this.modal.updateOne({ id: body.id  }, { imgUrl: body.imgUrl })
        }
    }


}

module.exports = placeIntro
